package com.li.controller;

import com.alibaba.fastjson.JSON;
import com.google.gson.GsonBuilder;
import com.li.pojo.dto.ContractPageDto;
import com.li.pojo.dto.CountDto;
import com.li.pojo.dto.ReportDto;
import com.li.pojo.po.PageResult;
import com.li.pojo.po.Result;
import com.li.pojo.vo.ImageReportVo;
import com.li.pojo.vo.ReportVo;
import com.li.service.ContractService;
import com.li.service.ImageReportService;
import com.li.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

//报表接口
@RestController
@Slf4j
@RequestMapping("/report")
public class ImageReportController {
    @Autowired
    private ImageReportService imageReportService;

    @GetMapping("/contractStatistics/{beginCreateTime}/{endCreateTime}")
    public ImageReportVo contractStatistics(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")  LocalDate beginCreateTime, @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endCreateTime){
        ImageReportVo imageReportVo =imageReportService.contractStatistics(beginCreateTime,endCreateTime);
        String s = JSON.toJSONString(imageReportVo);
        return imageReportVo;
    }



    @GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
    public ImageReportVo cluesStatistics(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")  LocalDate beginCreateTime, @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endCreateTime){
        ImageReportVo imageReportVo =imageReportService.cluesStatistics(beginCreateTime,endCreateTime);
        String jsonString = JSON.toJSONString(imageReportVo);
        return imageReportVo;
    }

    @GetMapping("/salesStatistics/{beginCreateTime}/{endCreateTime}")
    public ImageReportVo salesStatistics(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")  LocalDate beginCreateTime, @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endCreateTime){
        ImageReportVo imageReportVo =imageReportService.salesStatistics(beginCreateTime,endCreateTime);
        String jsonString = JSON.toJSONString(imageReportVo);
        return imageReportVo;
    }

    @GetMapping("/contractStatisticsList")
    public PageResult contractStatisticsList(CountDto countDto){
        PageResult pageResult =imageReportService.findCountByPage(countDto);
        return pageResult;
    }

//    @GetMapping("/cluesStatisticsList")
//    public PageResult cluesStatisticsList(CountDto countDto){
//        PageResult pageResult =imageReportService.cluesStatisticsList(countDto);
//        return pageResult;
//    }
}
